//
// Created by lin on 8/25/2021.
//

#ifndef CPPCHECK_CHECKCUSTOM_H
#define CPPCHECK_CHECKCUSTOM_H

#include "check.h"

#include <string>
#include "valueflow.h"

class ErrorLogger;
class Settings;
class Token;
class Tokenizer;

/**
 * 自定义规则
 */
class CPPCHECKLIB CheckCustom : public Check {
public:
    /** @brief This constructor is used when registering the CheckClass */
    CheckCustom() : Check(myName()) {
    }

    /** @brief This constructor is used when running checks. */
    CheckCustom(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
            : Check(myName(), tokenizer, settings, errorLogger) {
    }

    /** @brief Run checks against the normal token list */
    void runChecks(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) OVERRIDE {
        CheckCustom checkCustom(tokenizer, settings, errorLogger);

        // Checks
        checkCustom.checkCustomException();

    }

    // 检查自定义异常
    void checkCustomException();

private:

    void customError();

    void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {
        CheckCustom c(nullptr, settings, errorLogger);
        c.customError();
    }

    static std::string myName() {
        return "Custom";
    }

    std::string classInfo() const OVERRIDE {
        return "Custom Check";
    }
};

#endif //CPPCHECK_CHECKCUSTOM_H
